<% import grails.persistence.Event %>
<% import org.codehaus.groovy.grails.plugins.PluginManagerHolder %>
<%=packageName%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="\${message(code: '${domainClass.propertyName}.label', default: '${className}')}" />
        <title><g:message code="default.edit.label" args="[entityName]" /></title>
        <g:javascript src="jquery.placeholder.js" />
				<g:javascript>
					jQuery.noConflict();
					\$(document).ready(function() {
						\$('[placeholder]').placeholder();
					});
				</g:javascript>
    </head>
    <body>
        <div class="nav">
					<img src="\${resource(dir:'images/icons', file:'home_32.png')}"><a class="home" href="\${createLink(uri: '/')}"><g:message code="default.home.label"/></a>
					<img src="\${resource(dir:'images/icons', file:'list.png')}"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link>
					<img src="\${resource(dir:'images/icons', file:'add.png')}"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link>
        </div>
        <div class="body">
            <!--<h1><g:message code="default.edit.label" args="[entityName]" /></h1>-->
            <g:if test="\${flash.message}">
            <div class="message canhide">
							\${flash.message}
						</div>
            </g:if>
            <g:hasErrors bean="\${${propertyName}}">
            <div class="errors canhide">
							<g:renderErrors bean="\${${propertyName}}" as="list" />
            </div>
            </g:hasErrors>
            <g:form method="post" onsubmit="\$('[placeholder]').placeholder('clear');" <%= multiPart ? ' enctype="multipart/form-data"' : '' %>>
							<g:hiddenField name="id" value="\${${propertyName}?.id}" />
							<g:hiddenField name="version" value="\${${propertyName}?.version}" />
							<div class="dialog">
								<p>
									<%  excludedProps = Event.allEvents.toList() << 'version' << 'id' << 'dateCreated' << 'lastUpdated'
											persistentPropNames = domainClass.persistentProperties*.name
											props = domainClass.properties.findAll { persistentPropNames.contains(it.name) && !excludedProps.contains(it.name) }
											Collections.sort(props, comparator.constructors[0].newInstance([domainClass] as Object[]))
											display = true
											boolean hasHibernate = PluginManagerHolder.pluginManager.hasGrailsPlugin('hibernate')
											props.each { p ->
											if (hasHibernate) {
												cp = domainClass.constrainedProperties[p.name]
												display = (cp?.display ?: true)
											}
											if (display) { %>
												<label for="${p.name}"><g:message code="${domainClass.propertyName}.${p.name}.label" default="${p.naturalName}" /></label>
													${renderEditor(p)}
									<%  }   } %>
								</p>
							</div>
							<div class="buttons">
								<g:actionSubmit class="button-update" action="update" value="\${message(code: 'default.button.update.label', default: 'Update')}" />
								<g:actionSubmit class="button-delete" action="delete" value="\${message(code: 'default.button.delete.label', default: 'Delete')}"
									onclick="return confirm('\${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
							</div>
            </g:form>
        </div>
    </body>
</html>
